<%-- 
    Document   : astaDetails
    Created on : 4-gen-2013, 16.40.17
    Author     : Luciano
--%>


<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.UM"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Asta"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.User"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.items.Product"%>
<%@page import="it.unitn.science.matr155863_148346_145963.bccastestore.DBManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>

        <%
        Asta a;
        if(request.getAttribute("asta")!=null){
            a=(Asta)request.getAttribute("asta");
        }else if(session.getAttribute("asta")!=null){
            a=(Asta)session.getAttribute("asta");
            session.removeAttribute("asta");
        }else{
            request.setAttribute("error_message", "Unable to find your asta");
            throw new Exception();
        }
        String mess=null;
         if(request.getAttribute("mess")!=null){
            mess=(String)request.getAttribute("mess");
         }else if(session.getAttribute("mess")!=null){
            mess=(String)session.getAttribute("mess");
            session.removeAttribute("mess");
         }
         Product product = a.getProduct();
         request.setAttribute("product", product);
         
        %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Asta Details</title>
    </head>
    <body>
        <h2>Asta details:</h2>
        <jsp:include page="./productDetails" flush="true" />
        <div class="content">
            <%=mess!=null? "<h2>"+mess+"</h2>":""%>
            <%=a.getAnnulled()? "<h2>This asta is annulled.</h2>":""%>
                <table>
                  <tr>
                      <td><h4>Seller:</h4></td>
                      <td><h4>Quantity: </h4></td>
                      <td><h4>Min Price:</h4></td>
                      <td><h4>Min Increment:</h4></td>
                      <td><h4>Start Price:</h4></td>
                      <td><h4>Unita mis: </h4></td>
                      <td><h4>Price: </h4></td>
                      <td><h4>Shipping Price: </h4></td>
                      <td><h4>Deadline: </h4></td>
		  </tr>
		  <tr>
		      <td><a href="<%=response.encodeURL(request.getContextPath()+"/contents/user/userDetails?id="+product.getSellerId())%>"
                           ><p><%=a.getProduct().getSellerName()%></p> </a></td>
                      <td><p><%=a.getQuantity()%></p></td>
                      <td><p><%=a.getMin_price()%> euro ;</p></td>
                      <td><p><%=a.getMin_increment()%> euro ;</p></td>
                      <td><p><%=a.getStart_price()%> euro ;</p></td>
                      <td><p><%=a.getProduct().getUmName()%></p></td>
                      <td><p><%=a.getLast_offer_price()==null? "no offert":a.getLast_offer_price()%></p></td>
                      <td><p><%=a.getShippingPrice()%></p></td>
                      <td><p><%=a.getDate()%></p></td>
		  </tr>
                </table>
                      <a href="<%=response.encodeURL(request.getContextPath()+
                      "/contents/user/showOffers?asta_id="+a.getId())%>" >View offers made</a>
        </div>
    </body>
</html>
